package com.ddd.test.aggregate.aggrorder;


import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 订单聚合根
 *
 * 
 */
public class OrderEntity implements Serializable {

  private String orderNumber;

  private Integer count;

  private BigDecimal price;

  private String product;
  
  private String salesCode;
  
  private BigDecimal amount;
  
  private static final long serialVersionUID = 1L;

  //工厂方法
  public static OrderEntity createOrderEntity(String orderNumber,String product,Integer count,BigDecimal price,String salesCode){
      
      return new OrderEntity(orderNumber,product,count,price,salesCode);
  }

  protected OrderEntity(String orderNumber,String product,Integer count,BigDecimal price,String salesCode){
      this.orderNumber = orderNumber;
      this.product = product;
      this.count = count;
      this.price = price;
      this.salesCode = salesCode;
      this.amount = account();
  }

  public String getOrderNumber() {
    return orderNumber;
  }

  public void setOrderNumber(String orderNumber) {
    this.orderNumber = orderNumber == null ? null : orderNumber.trim();
  }

  public Integer getCount() {
    return count;
  }

  public void setCount(Integer count) {
    this.count = count;
  }

  public BigDecimal getPrice() {
    return price;
  }

  public void setPrice(BigDecimal price) {
    this.price = price;
  }
  public BigDecimal getAmount() {
	    return amount;
  }

  public void setAmount(BigDecimal amount) {
	    this.amount = amount;
  }
  public String getProduct() {
    return product;
  }

  public void setProduct(String product) {
    this.product = product == null ? null : product.trim();
  }
  
  public String getSalesCode() {
	return salesCode;
  }

  public void setSalesCode(String salesCode) {
	this.salesCode = salesCode == null ? null : salesCode.trim();
  }
  
  /**
   * 计算总金额
   *
   *
   */
  public BigDecimal account() {
  
    return this.price.multiply(new BigDecimal(this.count));
  }

}